/*
===========================================================================
This source file is part of DyLab (Dynamic Laboratory)
For the latest info, see http://dylab.googlecode.com

Copyright (c) 2006-2008 Lukas Krejci
(krejci.lukas@volny.cz)

This file is part of DyLab.

    DyLab is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DyLab is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DyLab.  If not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/

#ifndef __dylab_ITetrahedralVolumeFeature_h__
#define __dylab_ITetrahedralVolumeFeature_h__

//===========================================================================================
#include <dylab/simobject/ComModelStructure.h>
#include <dylab/simobject/tetravol/Edge.h>
#include <dylab/simobject/tetravol/Triangle.h>
#include <dylab/simobject/tetravol/Tetrahedron.h>

//===========================================================================================
namespace dylab {

    /** This class defines the interface for tetrahedral volume model structure representation.
	*/
    class DYLAB_EXPORT ITetrahedralVolumeFeature
		: virtual public ComModelStructure::IFeature
    {
    public:

        /** Fills the specified cube with with 5 tetrahedrons.
        @remarks 
			Cube is defined by 2 face squares, one ordered CCW and the other CW.
        */
        virtual void generateCubeSection(MassPoint::id_t _mp1, MassPoint::id_t _mp2, 
			MassPoint::id_t _mp3, MassPoint::id_t _mp4, MassPoint::id_t _mp5, 
			MassPoint::id_t _mp6, MassPoint::id_t _mp7, MassPoint::id_t _mp8) = 0;

		/** Creates a new tetrahedron and returns its ID.
		@remarks
			The new tetrahedron is specified by its 4 mass points
			identified by the 4 given IDs.
		@param[in] _mp1
			The ID of the first tetrahedron's mass point.
		@param[in] _mp2
			The ID of the second tetrahedron's mass point.
		@param[in] _mp3
			The ID of the third tetrahedron's mass point.
		@param[in] _mp4
			The ID of the fourth tetrahedron's mass point.
		@returns
			The ID of the newly created tetrahedron.
		*/
		virtual Tetrahedron::id_t createTetrahedron(MassPoint::id_t _mp1, MassPoint::id_t _mp2, 
			MassPoint::id_t _mp3, MassPoint::id_t _mp4) = 0;

		/** Destroys an existing tetrahedron.
		@param[in] _tetraID
			The ID of tetrahedron that should be destroyed.
	    */
        virtual void destroyTetrahedron(Tetrahedron::id_t _tetraID) = 0;

        /** Subdivides a tetrahedron by an inner point.
		@remarks
			Creates 4 new tetrahedra formed by the specified point and the corresponding opposite 3 points,
			and then destroys the original tetrahedron.
        @attention
			The point should not lie on any face or edge of the tetrahedron.
		@param[in] _tetraID
			The ID of the tetrahedron that should be subdivided.
		@param[in] _point
			The Point that subdivides the tetrahedron.
        */
        virtual void subdivideTetrahedron(Tetrahedron::id_t _tetraID, const Vector3 & _point) = 0;

		/** 
	    */
        virtual void subdivideEdge(Edge::id_t _edgeID, const Vector3 & _point) = 0;

		/**  
	    */
        virtual void subdivideTriangle(Triangle::id_t _triID, const Vector3 & _point) = 0;
		/**  
	    */
        virtual void collapseEdge(Edge::id_t _edgeID) = 0;
		/**  
	    */
        virtual EdgeContainer::Iterator edgeIterator() = 0;
		/**  
	    */
        virtual EdgeContainer::ConstIterator edgeIterator() const = 0;
		/**  
	    */
        virtual EdgeContainer::Reader edgeReader() const = 0;
		/**  
	    */
        virtual TriangleContainer::Iterator triangleIterator() = 0;
		/**  
	    */
        virtual TriangleContainer::ConstIterator triangleIterator() const = 0;
		/**  
	    */
        virtual TriangleContainer::Reader triangleReader() const = 0;
		/**  
	    */
        virtual TetrahedronContainer::Iterator tetrahedronIterator() = 0;
		/**  
	    */
        virtual TetrahedronContainer::ConstIterator tetrahedronIterator() const = 0;
		/**  
	    */
        virtual TetrahedronContainer::Reader tetrahedronReader() const = 0;
		/**  
	    */
        virtual void prepareForRendering() = 0;
    };

}
//===========================================================================================
#endif // __dylab_ITetrahedralVolumeFeature_h__
